package ipe.test;

import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.app.ActionBar;


@SuppressLint("NewApi")
public class MainActivity extends Activity {

	public final static String MSG2DISP = "MSG2DISP";
	
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
	     switch (item.getItemId()) {
		     case R.id.menu_quit:
		    	 menuQuitClick(findViewById(R.id.menu_quit));
		    	 return true;
		     default:
		    	 return super.onOptionsItemSelected(item);
		 }
    }
    //----------------------------------------------------------------------------------------------------------
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Utils.log("Test");
        setContentView(R.layout.activity_main);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // Show the Up button in the action bar.
            getActionBar().setDisplayHomeAsUpEnabled(true);
            getActionBar().setDisplayOptions(1,ActionBar.NAVIGATION_MODE_TABS);
            
        }

    }
    //----------------------------------------------------------------------------------------------------------
    @Override
    protected void onStart() {
    	super.onStart();
    	Utils.log("Far.. Errrm starting...");
    }
    //----------------------------------------------------------------------------------------------------------
    @Override
    protected void onResume() {
    	super.onResume();
    	Utils.log("Resuming");
    }
    //----------------------------------------------------------------------------------------------------------

    public void onWindowFocusChanged (boolean hasFocus) {
    	if (hasFocus) Utils.log("Got focus...");
    	else Utils.log("Lost focus");
    }
    //----------------------------------------------------------------------------------------------------------
    /*@Override
    protected void onStop() {
    	super.onStop();
    	Utils.log("Stopping...");
    }*/
    //----------------------------------------------------------------------------------------------------------
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    //----------------------------------------------------------------------------------------------------------
    public void doritiClick(View v){
    	Intent intent = new Intent(this, doritiActivity.class);
    	EditText editText = (EditText) findViewById(R.id.msgtext);
    	intent.putExtra(MSG2DISP, editText.getText().toString());
    	startActivity(intent);
    }
    //----------------------------------------------------------------------------------------------------------
    public void menuQuitClick(View v){
    	quit();
    }
    //----------------------------------------------------------------------------------------------------------

    public void quit(){
    	finish();
    }
    
        
}
